import resources.Constants;
import registnet.dao.StudentClassificationPeer;
import registnet.dao.StudentClassification;


/* [start]	automatically updates the 'to' value of academic year based on the
			current 'from' value of the academic year */
private void updateAY(){
	try{
		year2.value = (Integer.parseInt(event.value) + 1).toString();
	}catch(Exception e) {year1.value = null; year2.value = null;}
}
/* [end] */



private class FrequencyRenderer implements RowRenderer  {
	public void render(Row row, java.lang.Object data) {
		new Label(data[0]).setParent(row);
		new Label(data[1]).setParent(row);
	}
}



void submit(){
	Integer semesterValue = Constants.MAP_SEMESTER_KEY.get(semester.getSelectedItem().getLabel());
	Integer yearValue;
	if (semesterValue == Constants.MAP_SEMESTER_KEY.get(Constants.SUMMER))
		yearValue = Integer.parseInt(year2.value);
	else
		yearValue = Integer.parseInt(year1.value);
		
	HashMap map = new HashMap();
	for(int i=0; i<Constants.CLASSIFICATION.length; i++){
		map.put(Constants.CLASSIFICATION[i], 0);
	}
	
	List classifications = new StudentClassificationPeer().getAllClassifications(semesterValue, yearValue);
	for(int i=0; i<classifications.size(); i++){
		map.put(Constants.MAP_CLASSIFICATION_VALUE.get(classifications.get(i).getClassification()), map.get(Constants.MAP_CLASSIFICATION_VALUE.get(classifications.get(i).getClassification())) + 1);
	}
	
	String[][] listModel = new String[map.size()][2];
	for(int i=0; i<Constants.CLASSIFICATION.length; i++){
		listModel[i][0] = Constants.CLASSIFICATION[i];
		listModel[i][1] = "" + map.get(Constants.CLASSIFICATION[i]);
	}
	ListModel strset = new SimpleListModel(listModel);
	contents_win.getFellow("frequency_g").setModel(strset);
	contents_win.getFellow("frequency_g").setRowRenderer(new FrequencyRenderer());
}